<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>"延川县“三规合一”辅助选址"</title>
<link href='./css/bootstrap.min.css' rel='stylesheet' />
<jsp:include page="/commonPages/admin-meta.jsp" flush="true" />
<!-- CSS files -->
<jsp:include page="/commonPages/admin-style.jsp" flush="true" />

<style type="text/css">
body {
	margin: 0;
	overflow: hidden;
	background: #fff;
}

#map {
	position: relative;
	height: 520px;
	border: 1px solid #3473b7;
}

#toolbar {
	position: relative;
	height: 33px;
	padding-top: 5;
}

.win_bg {
	background: #CCC;
	opacity: 0.2;
	filter: alpha(opacity = 20);
	position: absolute;
	left: 0px;
	top: 0px;
	width: 100%;
	height: 100%;
	z-index: 998;
}

.winTitle {
	background: #4192c9;
	height: 20px;
	line-height: 20px;
	position:relative;
}

.winTitle .title_left {
	font-weight: bold;
	color: #FFF;
	padding-left: 5px;
	float: left
}

.winTitle .title_right {
	float: right;
	padding-right: 3px;
}

.winTitle .title_right a {
	color: #FFF;
	text-decoration: none;
	padding-right: 3px;
}

.winTitle .title_right a:hover {
	text-decoration: underline;
	color: #FF0000;
	padding-right: 3px;
}

.transferPreference {
	border: 1px solid #D6E3F1;
	height: 20px;
	margin: 1px 30%;
	padding: 0 12px;
}

.winContent {
	padding: 5px;
	overflow-y: auto;
	height: 550px;
}

.popupWindow {
	right: 680px;
	top: 105px;
	position: absolute;
	width: 1000px;
	height: 600px;
	border: 2px solid #D6E3F1;
	background: #FFF;
	z-index: 9999;
}
.button1{
	background-color:#4192c9;
	border:none;
	color:white;
	pading:15px 32px;
	text-align:center;
	text-decoration:none;
	display:inline-block;
	font-size:16px;
	margin:4px 2px;
	cursor:pointer;
	
	
}
</style>
<script src='./libs/SuperMap.Include.js'></script>
<script src='./js/jquery.js'></script>
 <script type="text/javascript">
           
            var map, local, vectorLayer,baseLayer, resultLayer, Spatialanalyst_sample,
            style = {
                strokeColor: "#343434",
                strokeWidth: 0.1,
                pointerEvents: "visiblePainted",
                fill: true,
                fillColor: "#304DBE",
                fillOpacity: 0.8
            };
            var featureReasult = new SuperMap.Feature();
            var ResultData = [];
            var result = null;
      
            //var url2 = " http://222.25.188.1:50118/iserver/services/spatialAnalysis-KongZhiXianJianCe/restjsr/spatialanalyst";
            var url2 = "http://222.25.188.1:50118/iserver/services/data-jingjin/rest/data";
            var url = "http://222.25.188.1:50118/iserver/services/map-SJK2/rest/maps/CZZTGHPHT";
            function init(){
            	//var url="http://222.25.188.1:50118/iserver/services/map-KongZhiXianJianCe/rest/maps/多规合一空间布局一张图@控制线检测";
        		
        		map = new SuperMap.Map("map");
        		
        		baseLayer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url , {transparent: true, cacheEnabled: true}, {maxResolution:"auto"});
                baseLayer.events.on({"layerInitialized": addLayer});
                resultLayer = new SuperMap.Layer.Vector("叠加结果");
                resultfeature = new SuperMap.Layer.Vector("查找结果");
                vectorLayer = new SuperMap.Layer.Vector("Vector Layer");
                
            }

            function addLayer() {
                map.addLayers([baseLayer, vectorLayer]);
                map.setCenter(new SuperMap.LonLat(37426892.09 , 4083177.09), 0);
                //map.allOverlays = true;
            }
            
            
			
			
			
			window.closeWindow = function() {
				$("#popupWin").css("display", "none");
			}
			window.startMove = function(o, e) {
				var wb;
				if (SuperMap.Browser.name === "msie" && e.button === 1)
					wb = true;
				else if (e.button === 0)
					wb = true;
				if (wb) {
					var x_pos = parseInt(e.clientX - o.parentNode.offsetLeft);
					var y_pos = parseInt(e.clientY - o.parentNode.offsetTop);
					if (y_pos <= o.offsetHeight) {
						document.documentElement.onmousemove = function(mEvent) {
							var eEvent = (SuperMap.Browser.name === "msie") ? event
									: mEvent;
							o.parentNode.style.left = eEvent.clientX - x_pos + "px";
							o.parentNode.style.top = eEvent.clientY - y_pos + "px";
						}
					}
				}
			}
			window.stopMove = function(o, e) {
			document.documentElement.onmousemove = null;
			}
			
            function overlayAnalystFailed(args) {
                alert(args.error.errorMsg);
                //alert("ajsdgjasgdjsadgsjahdgsajd");
            }

            function removeResult() {
                resultLayer.removeAllFeatures();
            }
           
            function selectTiaojian(){
            	var resultHtml =
            		
       				
       				"<table  class = 'table table-striped table-bordered table-hover' id ='list_Pro' >"
            		+"<tr> "+
       				"项目类别:"  + '<select id = "ProType" name = "ProType">'
       				+'<option value = "Pro1">'+"政府投资项目 "+'</option>'
       				+'<option value = "Pro2">'+"企业投资项目 "+'</option>'
       				
       				+'</select>'
       				+"</tr>"+"<br/><br/>"
       				+"<tr> "
       				+"选址方案:"  + '<select id = "ProSel" name = "ProSel">'
       				+'<option value = "ProS1">'+"工厂选址 "+'</option>'
       				+'<option value = "ProS2">'+"交通运输选址 "+'</option>'
       				+'<option value = "ProS3">'+"能源，水利选址"+'</option>'
       				+'<option value = "ProS4">'+"环境基础设施选址 "+'</option>'
       				+'<option value = "ProS5">'+"城市基础设施选址"+'</option>'
       				+'</select>'  +"</tr>"+"<br/><br/>"
       				+"<tr> "
       				+"用地性质  :"  + '<select id = "LandUse" name = "LandUse">'
       				+'<option value = "R1">'+"一类居住用地"+'</option>'
       				+'<option value = "R2">'+"二类居住用地 "+'</option>'
       				+'<option value = "R3">'+"三类居住用地"+'</option>'
       				+'<option value = "A1">'+"行政办公用地 "+'</option>'
       				+'<option value = "A2">'+"文化设施用地"+'</option>'
       				+'<option value = "A3">'+"教育科研用地"+'</option>'
       				+'<option value = "A4">'+"体育用地"+'</option>'
       				+'<option value = "A5">'+"医疗卫生用地 "+'</option>'
       				+'<option value = "A6">'+"社会福利设施用地"+'</option>'
       				+'<option value = "A7">'+"文物古迹用地"+'</option>'
       				+'<option value = "A8">'+"外事用地"+'</option>'
       				+'<option value = "A9">'+"宗教设施用地"+'</option>'
       				+'<option value = "B1">'+"商业用地"+'</option>'
       				+'<option value = "B1">'+"商务用地 "+'</option>'
       				+'<option value = "B3">'+"娱乐康体用地"+'</option>'
       				+'<option value = "B4">'+"公用设施营业网点用地"+'</option>'
       				+'<option value = "B9">'+"其他服务设施用地"+'</option>'
       				+'<option value = "M1">'+"一类工业用地"+'</option>'
       				+'<option value = "M2">'+"二类工业用地 "+'</option>'
       				+'<option value = "M3">'+"三类工业用地"+'</option>'
       				+'<option value = "W1">'+"一类物流仓储用地"+'</option>'
       				+'<option value = "W2">'+"二类物流仓储用地"+'</option>'
       				+'<option value = "W3">'+"三类物流仓储用地 "+'</option>'
       				+'<option value = "S1">'+"城市道路用地"+'</option>'
       				+'<option value = "S2">'+"轨道交通线路用地"+'</option>'
       				+'<option value = "S3">'+"交通枢纽用地"+'</option>'
       				+'<option value = "S4">'+"交通场站用地"+'</option>'
       				+'<option value = "S9">'+"其他交通设施用地"+'</option>'
       				+'<option value = "U1">'+"供应设施用地 "+'</option>'
       				+'<option value = "U2">'+"环境设施用地"+'</option>'
       				+'<option value = "U3">'+"安全设施用地"+'</option>'
       				+'<option value = "U9">'+"其他公用设施用地"+'</option>'
       				+'<option value = "G1">'+"公园绿地"+'</option>'
       				+'<option value = "G2">'+"防护绿地"+'</option>'
       				+'<option value = "G3">'+"广场用地"+'</option>'
       				
       				+'</select>'  +"</tr>"+"<br/><br/>"
       				+"<tr> "
       				+"<tr> "+
       				"用地面积 :"  + '<input type="text" id = "ProName" size = "5"/>'  +"至" + '<input type="text" id = "ProName1" size = "5"/>'+"(平方米)"+"</tr>"+"<br/><br/>"
       				+"区域选择    :  "  + '<input type="radio" name = "ProSize" value = "外部导入"/>'+"行政区域"
       				+ '<input type="radio" name = "ProSize" value = "手动绘制 "/>'+"手动绘制  "
       				+"</tr>"+"<br/><br/>"
       				+"统计级别   :  "  + '<input type="radio" name = "ProArea" value = "全县 "/>'+"全县 "
       				+ '<input type="radio" name = "ProArea" value = "街镇  "/>'+"街镇"
       				+"</tr>"+"<br/><br/>"
       				+"<tr> "
       			    + '<button class = "button1"  onclick = "ShowResult()">'+"下一步"+'</button>'        			   
    			    + '<input type="reset" name = "reset  " value = "清除"/>'  +"</tr>"+"<br/><br/>"
       				
       				        				
				
       				if (document.getElementById("popupWin")) {
   						$("#popupWin").css("display", "block");
   						//alert("jhgfjgfjsd");
   					} else {
   						$("<div id='popupWin'></div>").addClass("popupWindow").appendTo(
   								$("#result"));	
   					}
				var str = "";
				str += '<div class="winTitle" onMouseDown="startMove(this,event)" onMouseUp="stopMove(this,event)"><span class="title_left">上传项目文件   </span><span class="title_right"><a href="javascript:closeWindow()" title="关闭窗口">关闭</a></span><br style="clear:left"/></div>'; //标题栏

				str += '<div class="winContent" style="overflow-y:auto;height:400px;">';
				str += resultHtml;
				str += '</div>';
				//alert(str);
				$("#popupWin").html(str);
				document.getElementById("popupWin").style.width = "300px";
				document.getElementById("popupWin").style.height = "400px";
            	
				
            }
            function ShowResult(){
            	var begin = document.getElementById('ProName').value;
            	//var begin = 55182.547;
            	var landUse = document.getElementById('LandUse').value;
            	alert(landUse);
            	//var end = document.getElementById('ProName1').value;
            	//alert(begin);
            	 var queryParam, queryBySQLParams, queryBySQLService,getFeatureBySQLParams;
                 if(begin){ 
                 	queryParam = new SuperMap.REST.FilterParameter({
                     name: "CZZTGHPHT@SJK#1",
                     attributeFilter: "YQYDFL like "+"'" + landUse + "'" + "and "+"SmArea > " + begin
                 });
                 	
                 	}
                 else{
                 	alert("查询的Id不存在 ");
                 }
                //alert(queryParam);
                 queryBySQLParams = new SuperMap.REST.QueryBySQLParameters({
                     queryParams: [queryParam]
                 });
                 queryBySQLService = new SuperMap.REST.QueryBySQLService(url, {
                     eventListeners: {"processCompleted": processCompleted, "processFailed": processFailed}});
                 queryBySQLService.processAsync(queryBySQLParams);
            }
           

        function processCompleted(queryEventArgs) {
            var i, j, feature,
            result = queryEventArgs.result;
            //alert(result);
            if (result && result.recordsets) {
                for (i=0; i<result.recordsets.length; i++) {
                    if (result.recordsets[i].features) {
                        for (j=0; j<result.recordsets[i].features.length; j++) {
                            feature = result.recordsets[i].features[j];
                            ResultData.push(feature);
                            feature.style = style;
                            //vectorLayer.addFeatures(feature);
                        }
                    }
                }
            }
            var resultHtml ="<table  class = 'table table-striped table-bordered table-hover' id ='list_result' >"
   				
   				+"<tr>"
   				+"<th > 地块标号"+"</th>" 
   				+"<th>    用地类型"+"</th>"   				
   				+"<th>    面积  "+"</th>"   				
   				+"</tr>";
   			
   				//结果集为空
   				if(ResultData.length == 0){
   					alert("当前没有符合的数据");
   					if (document.getElementById("popupWin")) {
   						$("#popupWin").css("display", "block");
   						//alert("jhgfjgfjsd");
   					} else {
   						$("<div id='popupWin'></div>").addClass("popupWindow").appendTo(
   								$("#result"));	
   					}
   					
   					//$("#popupWin").css("display", "none");
   					var str = "";
   					str += '<div class="winTitle" onMouseDown="startMove(this,event)" onMouseUp="stopMove(this,event)"><span class="title_left">jieguoweikong</span><span class="title_right"><a href="javascript:closeWindow()" title="关闭窗口">关闭</a></span><br style="clear:left"/></div>'; //标题栏

   					str += '<div class="winContent" style="overflow-y:auto;height:400px;">';
   					str += resultHtml1;
   					str += '</div>';
   					//alert(str);
   					$("#popupWin").html(str);
   					document.getElementById("popupWin").style.width = "600px";
   					document.getElementById("popupWin").style.height = "432px";
   					
   					
   				}
   				//结果集中含有数据
   				else{
   					
   						
   					for(var i =0;i<ResultData.length;i++){	
   		       				resultHtml += '<tr onclick = "showfeature(\''+ResultData[i].attributes["SmID"]+'\')">'
   		       						  +"<td> "
   		       					+ ResultData[i].attributes["SmID"]+"</td>"
   		       					      +"<td> "+  ResultData[i].attributes["YQYDFL"] +"</td>"
   
   		       				          +"<td> "+  ResultData[i].attributes["SmArea"] +"</td>"
   		       			          
   		       		                  +"</tr>"
   		       		                 
   		       					+"</div>"
   					}
   					
   					if (document.getElementById("popupWin")) {
   						$("#popupWin").css("display", "block");
   						//alert("jhgfjgfjsd");
   					} else {
   						$("<div id='popupWin'></div>").addClass("popupWindow").appendTo(
   								$("#result"));	
   					}
   					
   					//$("#popupWin").css("display", "none");
   					var str = "";
   					str += '<div class="winTitle" onMouseDown="startMove(this,event)" onMouseUp="stopMove(this,event)"><span class="title_left">分析结果  </span><span class="title_right"><a href="javascript:closeWindow()" title="关闭窗口">关闭</a></span><br style="clear:left"/></div>'; //标题栏

   					str += '<div class="winContent" style="overflow-y:auto;height:400px;">';
   					str += resultHtml; 
   					
   					str += '</div>';
   					//alert(str);
   					$("#popupWin").html(str);
   					document.getElementById("popupWin").style.width = "600px";
   					document.getElementById("popupWin").style.height = "432px";
   					
   				}
   				
            
        }
        function processFailed() {
            //alert("asdasd");
        }
       
		
		
		window.closeWindow = function() {
			$("#popupWin").css("display", "none");
		}
		window.startMove = function(o, e) {
			var wb;
			if (SuperMap.Browser.name === "msie" && e.button === 1)
				wb = true;
			else if (e.button === 0)
				wb = true;
			if (wb) {
				var x_pos = parseInt(e.clientX - o.parentNode.offsetLeft);
				var y_pos = parseInt(e.clientY - o.parentNode.offsetTop);
				if (y_pos <= o.offsetHeight) {
					document.documentElement.onmousemove = function(mEvent) {
						var eEvent = (SuperMap.Browser.name === "msie") ? event
								: mEvent;
						o.parentNode.style.left = eEvent.clientX - x_pos + "px";
						o.parentNode.style.top = eEvent.clientY - y_pos + "px";
					}
				
			}
		}
		window.stopMove = function(o, e) {
		document.documentElement.onmousemove = null;
		}
        }
        function showfeature(SmID){
        	vectorLayer.removeAllFeatures();
        	
            //alert("jashdgjhsa");
        	for(var i=0;i<ResultData.length;i++){
        		
        		if(ResultData[i].attributes['SmID'] == SmID){
        			
        			var feature1,feature1s = [];	
        			feature1 = ResultData[i];
        			feature1.style ={
        	                strokeColor: "#FF3030",
        	                strokeWidth: 0.1,
        	                pointerEvents: "visiblePainted",
        	                fill: true,
        	                fillColor: "#304DBE",
        	                fillOpacity: 0.8
        	            };
        			feature1s.push(feature1);
        			
        			
        			vectorLayer.addFeatures(feature1s);
        		}
        		
        	}
        }
           
        </script>
    </head>
    <body onload="init()">
    <div id="wrapper">

		<!-- Navigation -->
		<jsp:include page="/commonPages/admin-navigator.jsp" flush="true" />
		<div id="page-wrapper">
		<div id='result' class='container'></div>
	
	
        <div id="toolbar">
        <form id = "uploadfile" method="post" action="" >
            <input type="button" class ="button1" value="选址条件设置" onclick="selectTiaojian()" />
        </form>    
           
            
        </div>
         <div id="map"></div>
       
	</div>
		<jsp:include page="/commonPages/admin-script.jsp" flush="true" />

	</div>
        
    </body>
</html>
